package com.xujl.mvcbind.ui.db.view;

import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.xujl.fastlib.base.BaseRvAdapter;
import com.xujl.fastlib.base.BaseView;
import com.xujl.fastlib.base.IControl;
import com.xujl.mvcbind.bean.OverTimeEntity;
import com.xujl.mvcbind.bean.OverTimePageEntity;
import com.xujl.mvcbind.databinding.FragmentOverTimeBinding;
import com.xujl.mvcbind.util.RefreshLayoutHelper;
import com.xujl.mvcbind.widget.ScrollSpeedLinearLayoutManger;
import com.xujl.mvcbind.window.MessageConfirmWindow;


/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class OverTimeFragmentView extends BaseView<FragmentOverTimeBinding> {
    private MessageConfirmWindow mConfirmWindow;

    @Override
    public void init (IControl control) {
        mBind.rv.setLayoutManager(new ScrollSpeedLinearLayoutManger(control.exposeContext()));
        mBind.refreshLayout.setOnRefreshLoadMoreListener((OnRefreshLoadMoreListener) control);
        mConfirmWindow = new MessageConfirmWindow(control.exposeContext());
    }

    public void setAdapter (BaseRvAdapter adapter) {
        mBind.rv.setAdapter(adapter);
    }

    public void initRefresh (RefreshLayoutHelper<OverTimeEntity> refreshLayoutHelper) {
        refreshLayoutHelper.setRecyclerView(mBind.rv)
                .setRefreshLayout(mBind.refreshLayout);
        RefreshLayoutHelper.refreshLayoutDefaultSetting(mBind.refreshLayout);
    }

    public void setPageData (OverTimePageEntity pageEntity) {
        mBind.setEntity(pageEntity);
    }

    public void showConfirmWindow (MessageConfirmWindow.Callback callback) {
        mConfirmWindow.showPopupWindow("确认删除本条记录，删除后无法恢复？", callback);
    }
}
